﻿using System.Windows.Media;

namespace Songhay.Silverlight.BiggestBox.IndexPart.ViewModels
{
    using Songhay.Mvvm.ViewModels;

    /// <summary>
    /// The color View Model for <see cref="KennyLayoutStatesViewModel"/>.
    /// </summary>
    /// <remarks>
    /// This type is based on the gallery sample “Dynamic Layout and Transitions in Blend 4”
    /// by Kenny Young, Expression Blend Architect
    /// [http://gallery.expression.microsoft.com/DynamicLayoutTrans/]
    /// </remarks>
    public class KennyColorViewModel : TinyViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="KennyColorViewModel"/> class.
        /// </summary>
        public KennyColorViewModel(string color)
        {
            this.Brush = new SolidColorBrush(ColorUtility.GetFromHexValue(color));
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="KennyColorViewModel"/> class.
        /// </summary>
        /// <param name="color">The color.</param>
        public KennyColorViewModel(Color color)
        {
            this.Brush = new SolidColorBrush(color);
        }

        /// <summary>
        /// Gets or sets the brush.
        /// </summary>
        /// <value>The brush.</value>
        public SolidColorBrush Brush
        {
            get { return this._brush; }
            set
            {
                this._brush = value;
                if(this._brush != null) this.Text = this._brush.Color.ToString();
                base.RaisePropertyChanged("Brush");
            }
        }

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        /// <value>The text.</value>
        public string Text
        {
            get { return this._text; }
            set
            {
                this._text = value;
                base.RaisePropertyChanged("Text");
            }
        }

        SolidColorBrush _brush;
        string _text;
    }
}
